import json
import logging
import logging.config
# 当前文件路径
import os
import sys
from logging.handlers import RotatingFileHandler

lib_root_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")

formatter = logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]:%(message)s')
handler1 = logging.StreamHandler()
handler1.setFormatter(formatter)
handler2 = RotatingFileHandler(
    os.path.join(os.getcwd(), "py_xcp_bridge" + '.log'), 
    maxBytes=1024*1024*10, 
    backupCount=5, 
    encoding='utf-8')
handler2.setFormatter(formatter)
logger = logging.getLogger()
logger.addHandler(handler1)
logger.addHandler(handler2)
logger.setLevel(logging.DEBUG)

def get_logger() -> logging.Logger:
    return logger